#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int minMaxGame(vector<int>& nums) {
        vector<int> v1(nums);
        vector<int> temp;
        while (v1.size() != 1)
        {
            for (int i = 0; i < v1.size() / 2; ++i)
            {
                if (i % 2)
                {
                    temp.push_back(max(v1[i * 2], v1[i * 2 + 1]));
                }
                else
                {
                    temp.push_back(min(v1[i * 2], v1[i * 2 + 1]));
                }
            }

            v1 = temp;
            temp.clear();
        }

        return v1[0];
    }
};